function M3Photographer() {
};

M3Photographer.instance = function(callbackFunc) {
  var popupBox = new PopupBox(), _self = this;
  
  var model = Model.instance('{{$smarty.const.MODEL_NAME_USER_PHOTOGRAPHER|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_USER_PHOTOGRAPHER|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_USER|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(0, 'Inactived', null);
  var state2 = State.instance(1, 'Choose a photographer', function(status, now) { return parseInt(((SimpleDate.toStamp(status.date) - (90 * 86400)) - SimpleDate.toStamp(now)) / 86400, 10); });
  var state3 = State.instance(2, 'Confirm with the photographer', function(status, now) { return parseInt(((SimpleDate.toStamp(status.date) - (40 * 86400)) - SimpleDate.toStamp(now)) / 86400, 10); });
  var state4 = State.instance(3, 'Remind the photographer', function(status, now) { return parseInt(((SimpleDate.toStamp(status.date) - (0 * 86400)) - SimpleDate.toStamp(now)) / 86400, 10); });
  var state5 = State.instance(4, 'Collect photo Dvd', function(status, now) { return parseInt(5 - ((SimpleDate.toStamp(now) - SimpleDate.toStamp(status.date)) / 86400), 10); });
  var state6 = State.instance(5, 'Backup photo Dvd', function(status, now) { return parseInt(3 - ((SimpleDate.toStamp(now) - SimpleDate.toStamp(status.date)) / 86400), 10); });
  var state7 = State.instance(6, 'Customers take photo Dvd', null);
  var state8 = State.instance(7, 'The Dvd has been taken', null);
  var transition1 = Transition.instance('Choose', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition2 = Transition.instance('Confirmed', state3, state4, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition3 = Transition.instance('Reminded', state4, state5, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition4 = Transition.instance('Collected', state5, state6, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition5 = Transition.instance('Backuped', state6, state7, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition6 = Transition.instance('Taken', state7, state8, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  var transition7 = Transition.instance('Remind', state7, state7, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}');
  
  transition3.validate = function(status, order, now, registrar) { return (transition3.assignee == registrar.type && ((SimpleDate.toStamp(now) - SimpleDate.toStamp(status.date)) / 86400) < 2); };
  transition7.validate = function(status, order, now, registrar) { return (transition7.assignee == registrar.type && ((SimpleDate.toStamp(now) - SimpleDate.toStamp(status.date)) / 86400) > 14); };

  transition1.custom = function(status, order, now, registrar, model, callbackFunc, pos, host) { var div = document.createElement('div');
                                                                                                 MiscUtils.dialog(popupBox, pos, div, null, null);
                                                                                                 var func = function() { transition1.operate(status, order, now, registrar, model, callbackFunc, host);
                                                                                                                         popupBox._close();
                                                                                                                       };
                                                                                                 new DialogAssignee(div, DlmanageUtils.trace(order, status), func, { php: null, condition: 'd.attribute.pEnabled = 1', close: function() { popupBox._close(); } });
                                                                                               };
  transition6.custom = function(status, order, now, registrar, model, callbackFunc, pos, host) { if (DlmanageUtils.pcompleted(order, DlmanageUtils.trace(order, status), 7)) {
                                                                                                   DlmanageUtils.produces(order, now);
                                                                                                 }
                                                                                                 transition6.operate(status, order, now, registrar, model, callbackFunc, host);
                                                                                               };
  model.states = [ state1, state2, state3, state4, state5, state6, state7, state8 ];
  model.transitions = [ transition1, transition2, transition3, transition4, transition5, transition6, transition7 ];
  return model;
};